﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Garden.Model;
using Kaixin.BLL;
using Kaixin.BLL.Helper;
using RegexHelper = Garden.Helper.RegexHelper;

namespace Garden.Func
{
    class HarvestMan : WorkMan
    {
        private List<Seed> _stealSeedList = GardenConfig.StealSeeds;
        
        public HarvestMan()
        {
            WhichPage = "havest";
        }
        protected override bool WorkCondition(Farmland land)
        {
            bool baseInfo =land.Status == 1 && land.Cropsstatus=="2" ;
            if (land.UID == "0")
            {
                return baseInfo && !land.IsLoveFarm;//TODO 暂时不收获爱心地
            }
            return baseInfo && !land.IsLoveFarm &&
                   land.Crops == FarmlandState.Normal && _stealSeedList.Exists(me => me.ID == land.Seed.ID);
        }

        protected override void WorkSummary(Farmland land, LogWrite log, string data)
        {
            string val = RegexHelper.GetFirstVal(data, RegexHelper.RetReg);
            string num = RegexHelper.GetFirstVal(data, RegexHelper.NumReg);
            if (land.UID == "0")
            {
                log(string.Format("{3}号地：收获{0}，共收获到{1}个{2}", val, num, RegexHelper.GetFirstVal(data, RegexHelper.SeedNameReg), land.FarmNum));
            }
            else
            {
                log(string.Format("{3}号地：偷取{0}，共偷到{1}个{2}", val, num, RegexHelper.GetFirstVal(data, RegexHelper.SeedNameReg), land.FarmNum));
            }
            
        }      
    }
}
